//导入包
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:path_provider/path_provider.dart';

//应用入口
void main() => runApp(MyApp());

class MyApp extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      //应用名称
      title: 'Flutter Demo',
      //主题
      theme: new ThemeData(
        primarySwatch: Colors.blue,
      ),
      //应用首页路由
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key? key, required this.title}) : super(key: key);

  final String title;
  @override
  State<StatefulWidget> createState() {
    return _MyHomePageState();
  }
}


class _MyHomePageState extends State<MyHomePage> {

   Directory? temporary;
   Directory? applicationDocuments;
   Directory? applicationSupport;

  @override
  void initState() {
    super.initState();
    getDirectory();
  }

  Future<void> getDirectory() async {
    temporary = await getTemporaryDirectory();
    applicationDocuments = await getApplicationDocumentsDirectory();
    applicationSupport = await getApplicationSupportDirectory();
  }

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text(widget.title),
      ),
      body: new Center(
        child: new Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            new Text(
                '''
                $temporary
                $applicationDocuments
                $applicationSupport
                '''
            ),
          ],
        ),
      ),
    );
  }
}
